package com.jumptap.adtag.actions;

import android.content.Context;
import android.util.Log;
import com.jumptap.adtag.JtAdView;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

public abstract class AdAction
{
  protected String redirectedUrl = null;
  protected String url = null;
  protected String useragent = null;

  public static String getRedirectedUrl(String paramString1, String paramString2)
  {
    DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient();
    HttpParams localHttpParams = localDefaultHttpClient.getParams();
    HttpClientParams.setRedirecting(localHttpParams, false);
    HttpConnectionParams.setSocketBufferSize(localHttpParams, 8192);
    try
    {
      HttpGet localHttpGet = new HttpGet(paramString1);
      localHttpGet.setHeader("User-Agent", paramString2);
      HttpResponse localHttpResponse = localDefaultHttpClient.execute(localHttpGet);
      if (localHttpResponse != null)
      {
        Header localHeader = localHttpResponse.getFirstHeader("Location");
        if (localHeader != null)
          return localHeader.getValue();
        Log.e("JtAd", "AdAction: cannot find Location header in the respons of :" + paramString1);
        return null;
      }
    }
    catch (Exception localException)
    {
      Log.e("JtAd", "getRedirectedUrl:" + localException.toString());
      return null;
    }
    Log.e("JtAd", "AdAction: cannot execute:" + paramString1);
    return null;
  }

  public static String getRedirectedUrlWithPredicate(String paramString1, String paramString2, UrlPredicate paramUrlPredicate)
  {
    int i = 0;
    while ((paramString1 != null) && (i < 4) && (!paramUrlPredicate.test(paramString1)))
    {
      i++;
      paramString1 = getRedirectedUrl(paramString1, paramString2);
    }
    if ("".equals(paramString1))
      paramString1 = null;
    return paramString1;
  }

  public abstract void perform(Context paramContext, JtAdView paramJtAdView);

  public void setRedirectedUrl(String paramString)
  {
    this.redirectedUrl = paramString;
  }

  public void setUrl(String paramString)
  {
    this.url = paramString;
  }

  public void setUserAgent(String paramString)
  {
    this.useragent = paramString;
  }

  public static abstract interface UrlPredicate
  {
    public abstract boolean test(String paramString);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.jumptap.adtag.actions.AdAction
 * JD-Core Version:    0.6.2
 */